package com.eastcom.groovy.test

import java.sql.Connection
import java.sql.DriverManager
import java.sql.ResultSet
import java.sql.Statement
/**
 * Created by yuanyue on 2014-08-05.
 */

               try {
                       Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();//加载驱动
                       Connection conn = DriverManager.getConnection("jdbc:derby:E:\\task_config;create=true");//连接数据库
                       Statement st = conn.createStatement();
//                       st.execute("create table TASK_CONFIG(\n" +
//                               "  task_id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,\n" +
//                               "  task_name VARCHAR(24) NOT NULL\n" +
//                               ")")
                        st.execute("")
//                       st.execute("create table FILE_CONFIG(\n" +
//                               "  task_id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,\n" +
//                               " task_name VARCHAR(24) NOT NULL,\n"+
//                               "  sql_delimiter VARCHAR(24) NOT NULL ,\n" +
//                               "  store_config_sql VARCHAR(512) NOT NULL ,\n" +
//                               "  get_config_sql VARCHAR(512) NOT NULL \n" +
//                               ")");//建表
//                       st.executeUpdate("insert into USER_INFOA(ID,NAME) values (1,'hermit')");//插入数据
//                       st.executeUpdate("insert into USER_INFOA(ID,NAME) values (2,'test')");//插入数据
//
//                        ResultSet rs = st.executeQuery("select * from USER_INFOA");//读取刚插入的数据
//                       while(rs.next()){
//                               int id = rs.getInt(1);
//                               String name = rs.getString(2);
//                               System.out.println("ID="+id);
//                                System.out.println("NAME="+name);
//                           }
                   conn.close();
                   } catch(Exception e){
                       e.printStackTrace();
                   }
